home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / xzmore < prev    next >
Encoding:
Text File  |  2010-11-11  |  2.1 KB  |  79 lines

  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2001, 2002, 2007 Free Software Foundation
  4. # Copyright (C) 1992, 1993 Jean-loup Gailly
  5.  
  6. # Modified for XZ Utils by Andrew Dudman and Lasse Collin.
  7.  
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12.  
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17.  
  18. #SET_PATH - This line is a placeholder to ease patching this script.
  19.  
  20. # Instead of unsetting XZ_OPT, just make sure that xz will use file format
  21. # autodetection. This way memory usage limit and thread limit can be
  22. # specified via XZ_OPT.
  23. xz='xz --format=auto'
  24.  
  25. version='xzmore (XZ Utils) 5.0.0'
  26.  
  27. usage="Usage: ${0##*/} [OPTION]... [FILE]...
  28. Like 'more', but operate on the uncompressed contents of xz compressed FILEs.
  29.  
  30. Report bugs to <lasse.collin@tukaani.org>."
  31.  
  32. case $1 in
  33.     --help)    echo "$usage" || exit 2; exit;;
  34.     --version) echo "$version" || exit 2; exit;;
  35. esac
  36.  
  37. oldtty=`stty -g 2>/dev/null`
  38. if stty -cbreak 2>/dev/null; then
  39.     cb='cbreak'; ncb='-cbreak'
  40. else
  41.     # 'stty min 1' resets eof to ^a on both SunOS and SysV!
  42.     cb='min 1 -icanon'; ncb='icanon eof ^d'
  43. fi
  44. if test $? -eq 0 && test -n "$oldtty"; then
  45.     trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
  46. else
  47.     trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
  48. fi
  49.  
  50. if test $# = 0; then
  51.     if test -t 0; then
  52.         echo "$usage"; exit 1
  53.     else
  54.         $xz -cdfq | eval "${PAGER:-more}"
  55.     fi
  56. else
  57.     FIRST=1
  58.     for FILE; do
  59.         < "$FILE" || continue
  60.         if test $FIRST -eq 0; then
  61.             printf "%s--More--(Next file: %s)" "" "$FILE"
  62.             stty $cb -echo 2>/dev/null
  63.             ANS=`dd bs=1 count=1 2>/dev/null`
  64.             stty $ncb echo 2>/dev/null
  65.             echo " "
  66.             case "$ANS" in
  67.                 [eq]) exit;;
  68.             esac
  69.         fi
  70.         if test "$ANS" != 's'; then
  71.             echo "------> $FILE <------"
  72.             $xz -cdfq -- "$FILE" | eval "${PAGER:-more}"
  73.         fi
  74.         if test -t 1; then
  75.             FIRST=0
  76.         fi
  77.     done
  78. fi
  79.